#ifndef __MOTOR_DRIVER_H
#define __MOTOR_DRIVER_H

#include "at32f415_wk_config.h"
#include <math.h>
#include <stdint.h>
#include "wk_tmr.h"

#define M_PI 3.1415926f
#define MOTOR_MAX_PWM_VALUE 4000
#define MOTOR_MAX_VOLTAGE 12 // V

#define MOTOR_PHASE_A 0
#define MOTOR_PHASE_B 1
#define MOTOR_PHASE_C 2

/*
初始化定时器等外设，初始化相关参数
*/
uint8_t MotorDriver_Init(void);

/*
根据pwm参数和供电电压参数，将电压值转为pwm占空比，并更新到寄存器
phase: 电机的ABC相
voltage: 电机的电压
*/
uint8_t MotorDriver_set_volatge(uint8_t phase ,float voltage);
uint8_t MotorDriver_set_volatge_three(float Va, float Vb, float Vc);


#endif







